<template>
    <div>
      <template v-for="item in this.menuTree">
          <el-submenu :index="item.id+''" :disabled="item.disabled" :key="item.id+''">
            <template slot="title">
              <i :class="item.icon"></i>
              <span>{{item.menuName}}</span>
            </template>
            <el-menu-item :index="child.id+''" v-for="child in item.children" :key="child.id+''"
                           :disabled="child.disabled" v-if="item.children.length>0" :route="child.url" @click="savePath(item.url)">
              <i :class="child.icon"></i>
              <span slot="title">{{child.menuName}}</span>
            </el-menu-item>

            <el-menu-item index="1111" route="/materials" @click="savePath('/main/materials')">
              <span slot="title">测试</span>
            </el-menu-item>
          </el-submenu>
      </template>
    </div>
</template>

<script>
  export default {
    name: 'MenuTree',
    props: ['menuTree'],
    methods: {
      //保存激活路径
      savePath(path) {
        window.sessionStorage.setItem("activePath", path);
        // 调用父组件的activePath
        this.activePath = path;
      },
    }
  }
</script>

<style scoped>
  .el-menu--collapse span,
  .el-menu--collapse i.el-submenu__icon-arrow {
    height: 0;
    width: 0;
    overflow: hidden;
    visibility: hidden;
    display: inline-block;
  }
</style>
